package com.totcy.atom;

import com.totcy.atom.utils.UserUtil;
import com.totcy.atom.view.activity.MainActivity;
import com.totcy.baselibrary.base.BaseApplication;
import com.totcy.baselibrary.utils.LogUtils;

import org.datatist.sdk.DatatistConfig;
import org.datatist.sdk.DatatistSDK;


/**
 * description: Application
 *
 * @author: Totcy
 * date: 2017/10/31 15:42
 * update: 2017/10/31
 */

public class MyApplication extends BaseApplication {

    private static MyApplication myApplication;

    @Override
    public void onCreate() {
        super.onCreate();
        myApplication = this;
        //log初始化,根据configUtil的isDebug参数控制是否显示log
        LogUtils.logInit(CommonValues.isRunningTest);
        initDatatist();
    }

    public static MyApplication getApplication() {
        return myApplication;
    }

    private void initDatatist() {

        //新版初始化
        DatatistSDK.init(this, new DatatistConfig.Builder()
                .trackerUrl("https://tracker.datatist.com/c.gif")
                .projectId("Zo2ZNvrxxHQNez4d")
                .siteId("51ix0Ikbr4DItX4p")
                .autoTrack(true)
                .appChannel("小米应用市场")
                //.debug(CommonValues.isRunningTest)
                .debug(true)
                .build());

        //设置UserId
        DatatistSDK.setUserId(UserUtil.getInstances().getUserName());
        //设置用户属性
        //DatatistSDK.setUserProperty(new JSONObject());


        //api 'com.datatist.android:DatatistSdk:2.2.6.1'

        //忽略一个页面事件采集
        DatatistSDK.ignoreAutoTrackActivity(MainActivity.class);
    }
}
